# -*- coding: utf-8 -*-
from datetime import datetime

from sc_engine.apps import messages as msgs

SCRIPT_NAME = 'ShinhanBankProleague0809'

name_key = u'ShinhanBankProleague0809'
name = u'Shinhan Bank Proleague 2008-2009'
alias = u'\uc2e0\ud55c\uc740\ud589 \ud504\ub85c\ub9ac\uadf8 08-09\uc2dc\uc98c'

five_game_format = {'number_of_games' : 5}
seven_game_format = {'number_of_games' : 7}

round_template = dict(name_key='Round%s', name='Round %s', format=five_game_format)
week_template = dict(name_key='Week%s', name='Week %s')
day_template = dict(name_key='Day%s', name='Day %s')


stage_template = [round_template, week_template, day_template]
stage_aliases = {
    u'3R 준플레이오프' : ['WinnersLeague', 'Playoffs', 'Quarterfinals'],
    u'3R 플레이오프' : ['WinnersLeague', 'Playoffs', 'Semifinals'],
    u'3R 결승' : ['WinnersLeague', 'Playoffs', 'Finals'],
}

stage_exceptions = [
    (
        ['Round3'], {
            'name_key' : 'WinnersLeague',
            'name' : 'Winner\'s League',
            'format' : seven_game_format,
        },
    ),

    (
        ['WinnersLeague', 'Playoffs'], {
            'name' : 'Playoffs'
        },
    ),

    (
        ['WinnersLeague', 'Playoffs', 'Quarterfinals'], {
            'name' : 'Quarterfinals',
        },
    ),

    (
        ['WinnersLeague', 'Playoffs', 'Semifinals'], {
            'name' : 'Semifinals',
        },
    ),

    (
        ['WinnersLeague', 'Playoffs', 'Finals'], {
            'name' : 'Finals',
        },
    ),
]

stage_known_dates = {
    datetime(2009,1,17) : ['WinnersLeague', 'Week1', 'Day1'],
    datetime(2009,2,14) : ['WinnersLeague', 'Week4', 'Day1'],
}

def run(bus):
    bus.send(msgs.LeagueDataTemplateAnnouncement(alias, name_key, name,
        stage_template, stage_known_dates, stage_aliases, stage_exceptions))
